﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace 学生信息管理系统
{
    public partial class Teacher : Form
    {
        public Teacher()
        {
            InitializeComponent();
        }

        private void Teacher_Load(object sender, EventArgs e)
        {

        }

        public Teacher(String s)
        {
            InitializeComponent();
            this.txtName.Text = s;
        }

        private void 显示学生信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "SELECT   学号, 姓名, 性别, 年龄, 备注   FROM      学生信息";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 编辑学生信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.IsMdiContainer = true;
            #region
            
            if (Application.OpenForms["TeacherSMessage"] == null)
            {
                TeacherSMessage child = new TeacherSMessage();
                child.MdiParent = this;
                child.Show();
            }
            else//有Name为FrmChildren的子船体，就直接show()
            {
                Application.OpenForms["TeacherSMessage"].Show();
            }
            #endregion

        }

        private void 修改登录密码ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TeacherPassword f = new TeacherPassword();
            f = new TeacherPassword(txtName.Text);
            DialogResult r = f.ShowDialog();
            this.IsMdiContainer = true;
            f.MdiParent = this;
        }

        private void 大一上学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "SELECT   大一上学期.*    FROM      大一上学期";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 大一下学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "SELECT   大一下学期.*    FROM      大一下学期";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 大二上学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "SELECT   大二上学期.*    FROM      大二上学期";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 大二下学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "SELECT   大二下学期.*    FROM      大二下学期";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 大三上学期ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string cn_str = pub.CN_STR;
            OleDbConnection cn = new OleDbConnection(cn_str);              //建立数据库连接
            cn.Open();
            string select = "SELECT   大三上学期.*    FROM      大三上学期";
            OleDbCommand cmd = new OleDbCommand(select, cn);                 //建立数据库命令
            OleDbDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            this.dataGridView1.DataSource = dt;
            cn.Close();
        }

        private void 编辑学生信息ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            //TeacherSScore f = new TeacherSScore();
            //this.IsMdiContainer = true;
            //f.MdiParent = this;
            //f.Show();

            this.IsMdiContainer = true;
            #region

            if (Application.OpenForms["TeacherSScore"] == null)
            {
                TeacherSScore child = new TeacherSScore();
                child.MdiParent = this;
                child.Show();
            }
            else//有Name为FrmChildren的子船体，就直接show()
            {
                Application.OpenForms["TeacherSScore"].Show();
            }
            #endregion

        }

        private void 返回主页面ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Login ff = new Login();
            ff.Show();
            this.Hide();
        }
      
    }

}
